﻿<div class="pagelist">
    <input type="hidden" id="pageindex" value="@Model.PageInfor.Index"/>
    <div class="l-btns">
        <span>显示</span><input id="txtPageNum" name="txtPageNum" type="text" value="@Model.PageInfor.Size" class="pagenum" onkeydown="return checkNumber(event);" /><span>条/页</span>
    </div>
    <div id="PageContent" class="default">
        <span>共@(Model.PageInfor.DataCount)记录</span>
        @{if (Model.PageInfor.Index <= 1)
          {
            @:<span class="disabled">«上一页</span>
              }
          else
          {
            @:<a href="@Html.Raw(Model.PageInfor.PageUrl((Model.PageInfor.Index - 1), Model.PageInfor.Size))">«上一页</a>
              }
        }@{if (Model.PageInfor.Index == 1)
           {
            @:<span class="current">1</span>
               }
           else
           {
            @:<a href="@Html.Raw(Model.PageInfor.PageUrl(1, Model.PageInfor.Size))">1</a>
               }
        }@{if (Model.PageInfor.Index >= 8)
           {
            @:<span>...</span>
                }
        }@for (var i = 2; i < Model.PageInfor.PageCount; i++)
         {
             if (0 < Model.PageInfor.Index - i && Model.PageInfor.Index - i <= 4)
             {
            @:<a href="@Html.Raw(Model.PageInfor.PageUrl(i, Model.PageInfor.Size))">@i</a>
                   }
             else if (0 < i - Model.PageInfor.Index && i - Model.PageInfor.Index <= 3)
             {
            @:<a href="@Html.Raw(Model.PageInfor.PageUrl(i, Model.PageInfor.Size))">@i</a>
                   }
             else if (Model.PageInfor.Index == i)
             {
            @:<span class="current">@i</span>
                   }
         }@{if (Model.PageInfor.PageCount - Model.PageInfor.Index >= 5)
            {
             @:<span>...</span>
                  }
         }@{if (Model.PageInfor.PageCount > 1)
            {
                if (Model.PageInfor.Index == Model.PageInfor.PageCount)
                {
             @:<span class="current">@Model.PageInfor.PageCount</span>
                       }
                else
                {
             @:<a href="@Html.Raw(Model.PageInfor.PageUrl(Model.PageInfor.PageCount, Model.PageInfor.Size))">@Model.PageInfor.PageCount</a>
                       }
            }
         }@{if (Model.PageInfor.PageCount > 1)
            {
                if (Model.PageInfor.Index >= Model.PageInfor.PageCount)
                {
             @:<span class="disabled">下一页»</span>
                        }
                else
                {
             @:<a href="@Html.Raw(Model.PageInfor.PageUrl((Model.PageInfor.Index + 1), Model.PageInfor.Size))">下一页»</a>
                        }
            }
         }
    </div>
</div>
<script type="text/javascript" language="javascript">
    $(function () {
        $("#txtPageNum").change(function () {
            var url = "@Html.Raw(Model.PageInfor.PageUrl(1, -1))";
            document.location.href = url.replace("=-1", "=" + $("#txtPageNum").val());
        });
    });
</script>
